package com.tcc.fastline.Helpers;

import java.util.List;

import com.tcc.fastline.Domain.*;
import com.tcc.smartqueue.R;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class GridViewGerenciarFilaAdapater extends BaseAdapter{

	private final Context context;
	private final List<IntegranteFila> values;
	
	
	
	public GridViewGerenciarFilaAdapater(Context context, List<IntegranteFila> values) {
		this.context = context;
		this.values = values;
	}
	
	@Override
	public int getCount() {
		return this.values.size();
	}

	@Override
	public Object getItem(int position) {
		return this.values.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

		View rowView = inflater.inflate(R.layout.gerenciar_fila_item, parent, false);

		TextView txtNomeUsuario = (TextView) rowView.findViewById(R.id.gerenciarFilaItem_NomeUsuario);
		TextView txtDataEntrada = (TextView) rowView.findViewById(R.id.gerenciarFilaItem_DataEntrada);
		TextView txtQtdePessoas = (TextView) rowView.findViewById(R.id.gerenciarFilaItem_QtdePessoas);
		TextView txtTextoDataEntrada = (TextView) rowView.findViewById(R.id.gerenciarFilaItem_TextoDataEntrada);
		TextView txtTextoQtdePessoas = (TextView) rowView.findViewById(R.id.gerenciarFilaItem_TextoQtdePessoas);
		
		txtNomeUsuario.setText(values.get(position).getUsuario().getNome());
		txtDataEntrada.setText(DateTime.formatDateTime(values.get(position).getDataEntrada()));
		txtQtdePessoas.setText(values.get(position).getQtdePessoas().toString());
		
		if(values.get(position).isPreferencial()){
			rowView.setBackgroundColor(Color.BLUE);
			txtDataEntrada.setTextColor(Color.WHITE);
			txtNomeUsuario.setTextColor(Color.WHITE);
			txtQtdePessoas.setTextColor(Color.WHITE);
			txtTextoDataEntrada.setTextColor(Color.WHITE);
			txtTextoQtdePessoas.setTextColor(Color.WHITE);
		}
		else{
			rowView.setBackgroundColor(Color.WHITE);
		}
		
		return rowView;
	}

}
